package cn.itcast.listener;

import cn.itcast.pojo.Student;
import com.alibaba.fastjson.JSON;
import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.stereotype.Component;

@Component
public class TopicaListener {
    @KafkaListener(topics = {"topica"})
    public void receiveMessage (ConsumerRecord<String,String> record){
        System.out.println(record.key());
        System.out.println(record.value());
        Student student = JSON.parseObject(record.value(), Student.class);
        System.out.println(student);
    }
}
